<%@page import="QRCG.DatabaseManager"%>
<%@page import="java.util.*"%>

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
	pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
	<title>Change Personal Information !!!</title>
	<link href="index.css" rel="stylesheet" type="text/css" />
	<script src="datetimepicker_css.js"></script>
</head>

<%@ include file="ProfileHeader.jsp" %>

<body>
  <%
  
    String nickname = (String) session.getAttribute("nickname");
  	if (nickname != null) {
  		
    DatabaseManager conn = new DatabaseManager();
    conn.connect();

    String name     = conn.getUserInformation(DatabaseManager.UserInformation.NAME, nickname);
    String surname  = conn.getUserInformation(DatabaseManager.UserInformation.SURNAME, nickname);
    String gender   = conn.getUserInformation(DatabaseManager.UserInformation.GENDER, nickname);
    String email    = conn.getUserInformation(DatabaseManager.UserInformation.EMAIL, nickname);
    String location = conn.getUserInformation(DatabaseManager.UserInformation.LOCATION, nickname);

    ArrayList<HashMap<String, Object>> LocList = conn
        .getAllLocations();
    int num_of_loc = LocList.size();
    System.out.println(num_of_loc);
  %>
	<div class="information-text">
		<table align="center">
			<tr>
				<td>You can now change your personal information here.</td>
			</tr>		
		</table>
	</div>
	<div id="post-form">
		<form name="ChangePersInfo" method="post" action="ChangePersInfoServe">
			<div id ="infotable">
				<table class="post-table">
					<tr>
						<td class="post-label" ><b>Name:</b></td>
						<td><input class="post-textbox" type="text" name="name" value=<%=name %> /></td>
					</tr>

					<tr>
						<td class="post-label"><b>Surname:</b></td>
						<td><input class="post-textbox" type="text" name="surname" value=<%=surname %> /></td>
					</tr>
					
					<tr>
						<td class="post-label"><b>e-mail:</b></td>
						<td><input class="post-textbox" type="text" name="email" value=<%=email%> /></td>
					</tr>

					<tr>
						<td class="post-label"><b>Gender:</b></td>
						<td align="left" width="10%"><input type="radio" name="gender" value="female">Female<input type="radio"name="gender" value="male" checked>Male</td>

					</tr>

					<tr>
						<td class="post-label"><b>Location:</b></td>
						<td><SELECT class="post-selection" name=Loc>
								<OPTION><%=location %></OPTION>
								<%
									for (int i = 0; i < num_of_loc; i++) {
										HashMap<String, Object> map = (HashMap<String, Object>) LocList
												.get(i);
								%>

								<OPTION><%=map.get("location_name")%></OPTION>
								<%
									}
								%>
						</SELECT></td>
					</tr>


					<tr>
						<td class="post-label"><b> Change Password:</b></td>
						<td><input class="post-textbox" type="password" name="pass1" /></td>
					</tr>


					<tr>
						<td class="post-label"><b>Verify Password:</b></td>
						<td><input class="post-textbox" type="password" name="pass2" /></td>
					</tr>


					<tr>
						<td/><td><input id="button-type" type="submit" value="Submit" /></td>
					</tr>
			</table>
		</div>
	</form>
	</div>
</body>
<%
	} else {
		response.sendRedirect("index.jsp");
	}
%>

<%@ include file="footer.jsp"%>